[diffusion] fix: restore nested condition rows in FlowGRPO actor replay - #534
Conversation
Ref2VA reference condition rows are padded to a global length and turned into jagged nested tensors by embeds_padding_2_no_padding. The FlowGRPO diffusion engine never restored them, so the MiniMax H3 Ref2VA adapter's [:, :count] slice on condition_video_rows raised 'RuntimeError: slice() not supported for NestedTensor on dim=0' before the first training step. Move _unpad_condition_rows from the DiffusionNFT engine into the shared DiffusersFSDPEngine base and call it from PPODiffusersFSDPEngine.forward path so condition rows reach the adapter as dense padded tensors; the adapter slices the first count rows on dim 1, which is the existing T2VA/ FL2VA behavior. AI assistance (pi coding agent) was used for this change. Co-authored-by: pi coding agent Signed-off-by: NancyFyong <2742092809@qq.com>
There was a problem hiding this comment.
🟢 Approval recommended
The fix is localized to engine-side input preparation, preserves existing NFT behavior via the base method, and is backed by targeted CPU regression tests for both success and validation failure paths.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
@SamitHuang @zhtmike PTAL |
|
verdict: fix is correct and minimal — hoist is behavior-preserving (body unchanged), all actor-replay/ref/teacher paths go through the one call site, fail-closed on bad masks. one coverage gap, then good to go.
AI assistance (ZCode) was used for this review. |
Drive the Ref2VA actor-replay test through the PPO diffusion engine so removing the condition-row unpadding call reproduces the original NestedTensor slice failure. AI assistance (pi coding agent) was used for this change. Co-authored-by: pi coding agent Signed-off-by: NancyFyong <2742092809@qq.com>
e18db29 to
3bcfc47
Compare
|
Addressed the coverage gap in 3bcfc47.
I also updated the PR test evidence with these results. Thanks for the precise review. AI assistance (pi coding agent) was used to prepare this response and change. |
What does this PR do?
Fixes a
RuntimeError: slice() not supported for NestedTensor on dim=0that blocksMiniMax H3 Ref2VA FlowGRPO training on current
main. T2VA and FL2VA areunaffected.
Ref2VA reference condition rows (
condition_video_rows/condition_audio_rows)are padded to a global length and turned into jagged nested tensors by
embeds_padding_2_no_padding. The FlowGRPO diffusion engine never restored themto dense tensors, so the MiniMax H3 Ref2VA adapter's
[:, :count]slice indiffusers_training_adapter.pycrashed before the first training step.Checklist Before Starting
open work is [3/N][diffusion, rollout, tests] refactor: unify diffusion rollout request contract #480 (rollout request refactor) and [doc, recipe] chore: document MiniMax H3 training support #529 (docs), which are
unrelated to nested condition rows.
[diffusion] fix: ...(validated withtests/special_sanity/check_pr_title.py).Test
CPU regression coverage in
tests/pipelines/test_minimax_h3_ref2va_flow_grpo_on_cpu.py:test_ref2va_actor_replays_full_layout_and_scores_only_targets: builds thecomplete Ref2VA replay micro-batch with nested condition rows and drives it
through
PPODiffusersFSDPEngine.prepare_model_inputs, verifying the enginerestores dense rows before the adapter performs
[:, :count]slicing.test_ref2va_engine_unpads_nested_condition_rows: directly covers denserestoration and row-count handling for heterogeneous nested rows.
test_ref2va_engine_rejects_mismatched_nested_mask: verifies nested rowswithout a nested mask fail closed.
Commands run (project venv, CPU):
Negative-control check: temporarily replacing
PPODiffusersFSDPEngine._unpad_condition_rowswith a no-op makes the fullactor-replay test fail with the original
RuntimeError: slice(): not supported for NestedTensor on dim=0.A stacked eight-GPU TinyRandom Ref2VA FlowGRPO smoke also completed one rollout
and actor-update step (
training/global_step: 1) and produced eight MP4s plusone JSONL rollout record.
Design & Code Changes
_unpad_condition_rowsfromNFTDiffusersFSDPEngineinto the sharedDiffusersFSDPEnginebase so it is available to all diffusion engines.self._unpad_condition_rows(micro_batch)inPPODiffusersFSDPEngine.prepare_model_inputsbefore delegating to the adapter, socondition rows reach the MiniMax H3 Ref2VA adapter as dense padded tensors.
_unpad_condition_rowsdefinition from the NFT engine(it inherits the base version; its existing call site still resolves correctly).
DPODiffusersFSDPEngineunchanged because there is no Ref2VA DPO pipeline.Checklist Before Submitting
mismatched-mask paths.
AI assistance
AI assistance (pi coding agent) was used for this change.
A human submitter (NancyFyong) reviewed every changed line and verified the
commands/results above.